function mSign_signMark_app() {
    var wrapper = document.getElementById("mSign_signMark_signature_pad"),
        clearButton = document.getElementById("mSign_signMark_clear_out"),
        canvas = wrapper.querySelector("canvas"),
        sureButton = document.getElementById("mSign_signMark_submit"),
        signaturePad;

    function resizeCanvas() {

        var ratio =  Math.max(window.devicePixelRatio || 1, 1);
        canvas.width = canvas.offsetWidth * ratio;
        canvas.height = canvas.offsetHeight * ratio;
        canvas.getContext("2d").scale(ratio, ratio);
    }

    window.onresize = resizeCanvas;
    resizeCanvas();

    signaturePad = new SignaturePad(canvas,{
        minWidth: 3,
        maxWidth: 5,
        penColor: "black"//签字笔颜色
    });

    clearButton.addEventListener("click", function (event) {
		sign = false;
        signaturePad.clear();
    });
    sureButton.addEventListener("click", function (event) {
        var imgBase64 = signaturePad.toDataURL();
		// console.log(imgBase64);
		// console.log(serviceNoticeId);
		// console.log(serviceNo);
		// console.log(enginnerId);

		if(!sign){
			app.toast("请签名")
			return
		}
		var emailAddress = h("#emailAddress").val();
		var ele = document.getElementsByName("checkbox1");
		var isSendEmail = "0";
		if(ele[0].checked){
			isSendEmail = "1";
			if(JS.IsNullOrEmpty(emailAddress)){
				app.toast("请填写邮箱")
				return
			}else{
				// var str = 'xxxx@126.com;123234234@qq.com;xxxxx@xxxxx.con.cn';
				var reg = /^((([A-Za-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6}\;))*(([A-Za-z0-9_\.-]+)@([\da-z\.-]+)\.([a-z\.]{2,6})))$/;
				if (!reg.test(emailAddress)) {
				 app.toast("请输入正确的邮箱，多个邮箱用;隔开");
				 return
				}
			}
		}
		// console.log(isSendEmail);
		ajaxPost(BASE_URL + "cc/service/report/getServiceRportSignature", {
			"serviceNoticeId": serviceNoticeId,
			"serviceNo": serviceNo,
			"enginnerId": enginnerId,
			"b": imgBase64,
			"isSendEmail": isSendEmail,
			"emailAddress": emailAddress
		}, function(data) {
			console.log(JSON.stringify(data))
			if (data.code == 200) {
				app.toast("签名成功");
			}else{
				app.toast(data.msg);
			}
			mui.back()
		}, function(errorMsg) {
			console.log(JSON.stringify(errorMsg))
		});
	
    });
}

